#include <iostream>
#include <deque>
using namespace std;
int n,k;
const int N=1e6+10;
int a[N];
int main()
{
	deque<int> q;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		while(q.size()&&a[q.back()]>=a[i])q.pop_back();
		q.push_back(i);
		if(i-q.front()+1>k)q.pop_front();
		if(i>=k)cout<<a[q.front()];
	}
	return 0;
}
